package cn.jcby.app.lebu.controller;


import cn.jcby.app.lebu.controller.res.DictRes;
import cn.jcby.app.lebu.service.DictService;
import cn.jcby.app.lebu.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * 字典表
 *
 * @author lht
 * @email 
 * @date 2023-12-07 15:13:35
 */
@RestController
@RequestMapping("lebu/dict")
@Api(tags="字典表")
public class DictController {
    @Autowired
    private DictService dictService;

    /**
     * 列表
     */
    @PostMapping("/list")
    @ApiOperation("列表")
    @ApiResponses({
          @ApiResponse(code = 200,message = "ok",response = DictRes.class)
    })
    public Result list(@RequestParam("parentCode")String parentCode){
        try {
            List<DictRes> list = dictService.listByParentCode(parentCode);
            return Result.ok().put("data", list);
        }catch (Exception e){
            e.printStackTrace();
            return Result.error(e.getMessage()) ;
        }
    }
}
